#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "settingdialog.h"
#include "sysinfothread.h"
#include "task.h"

#include <QMainWindow>
#include <QProcess>
#include <QTimer>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

#define ROOT_PATH QApplication::applicationDirPath()
const QString RED = "red";
const QString BLUE = "blue";
const QString GREEN = "green";

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    void enterRebootMode();
    void enterBookedMode();

private slots:
    void stopWork();
    void onTempError(QString temp);
    void onReadyReadStandardOutput();
    void onReadyReadStandardError();
    void onProcessFinished(int code);
    void onSettingFinished();
    void on_pushButton_clicked();

    void on_pushButton_2_clicked();

    void on_pushButton_3_clicked();

    void on_action_triggered();

    void on_action_2_triggered();

    void on_action_4_triggered();

    void on_action_wifi_triggered();

    void on_action_3_triggered();

    void on_action_5_triggered();

    void on_action_U_triggered();

    void on_action_6_triggered();

private:
    Ui::MainWindow *ui;
    QList<Task*> tasks;
    QProcess *p = nullptr;
    QTimer *timer = nullptr;
    SysInfoThread *sysInfoThread;
    SettingDialog settingDlg;
    int cid;
    bool isAutoMode = false;
    int stdCpuTemp = 85;
    int memId = 2;
    bool loadTaskFromConfig(QList<Task*> *tasks, QString config);
    void loadItems();
    void loadSlots();
    void loadOtherInfo();
    void doTask(int id);
    void doWork();
    QPair<bool, QString> doWorkCheck();
    void clearTestInfo();
    void appendLog(QString log, QString color="black");
    void startVideoTest();
    void testFail(QString error);
    void uploadReport(bool result);
};
#endif // MAINWINDOW_H
